package com.shuwen.gcdj.controller.statistics;

import com.shuwen.gcdj.bean.conditionMonitoring.request.*;
import com.shuwen.gcdj.bean.conditionMonitoring.response.*;
import com.shuwen.gcdj.common.annotation.JWTAuth;
import com.shuwen.gcdj.common.api.CommonResult;
import com.shuwen.gcdj.controller.AuthController;
import com.shuwen.gcdj.service.statistic.StatisticsHealthService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/***
 ** Created YangX
 ** Date:2023/5/9
 */
@Api(tags = "健康评估")
@RestController
@RequestMapping("/health")
@Slf4j
public class HealthMonitoringController extends AuthController {
    @Autowired
    private StatisticsHealthService statisticsHealthService;

    @ApiOperation(value = "获取整机健康度历史趋势数据")
    @PostMapping(value = "/getHistoryByCompleteMachineHealth")
    @JWTAuth
    public CommonResult<StatisticsHealthResp> getHistoryByCompleteMachineHealth(HttpServletRequest request, @RequestBody HealthQueryReq req, BindingResult results){

        return  statisticsHealthService.getHistoryByCompleteMachineHealth(req);
    }

    @ApiOperation(value = "获取起升机构健康度历史趋势数据")
    @PostMapping(value = "/getHistoryByHealth")
    @JWTAuth
    public CommonResult<List<StatisticsHealthResp>> getHistoryByHealth(HttpServletRequest request, @RequestBody HealthReq req, BindingResult results){

        return  statisticsHealthService.getHistoryByHealth(req);
    }

    @ApiOperation(value = "获取当前整机健康度数据")
    @PostMapping(value = "/getToDayMachineHealth")
    @JWTAuth
    public CommonResult<HealthyStatisticsRateResp> getToDayMachineHealth(@RequestBody StatisticsHealthSingleQueryReq req, BindingResult results){

        return  statisticsHealthService.getToDayMachineHealth(req);
    }

    @ApiOperation(value = "获取当前健康度数据")
    @PostMapping(value = "/getToDayCompleteMachineHealth")
    @JWTAuth
    public CommonResult<List<HealthyStatisticsRateResp>> getToDayCompleteMachineHealth(@RequestBody StatisticsHealthSingleQueryReq req){

        return  statisticsHealthService.getToDayCompleteMachineHealth(req);
    }

    @ApiOperation(value = "获取载荷数据")
    @PostMapping(value = "/getStatisticsOperatingmodeload")
    @JWTAuth
    public CommonResult<StatisticsHealthResp> getStatisticsOperatingmodeload(@RequestBody StatisticsHealthSingleQueryReq req){

        return  statisticsHealthService.getStatisticsOperatingmodeload(req);
    }

    @ApiOperation(value = "获取设备编号信息")
    @GetMapping(value = "/getEquipmentCodeList")
    @JWTAuth
    public CommonResult<List<EquipmentDictSettingResp>> getEquipmentCodeList(HttpServletRequest request, @RequestParam Integer area){
        return statisticsHealthService.getEquipmentCodeList(area);
    }

    @ApiOperation(value = "获取设备名称信息")
    @GetMapping(value = "/equipmentName/getEquipmentNameList")
    @JWTAuth
    public CommonResult<List<EquipmentDictSettingResp>> getEquipmentNameList(HttpServletRequest request, @RequestParam Integer area){
        return statisticsHealthService.getEquipmentNameList(area);
    }
}
